package top.saplf.library.ext

import android.content.Context
import android.content.res.TypedArray
import android.support.annotation.StyleableRes
import android.util.AttributeSet

/**
 * @author saplf
 */
inline fun AttributeSet?.use(
        context: Context,
        @StyleableRes styleable: IntArray,
        action: TypedArray.() -> Unit) {
    val typeArray = context.obtainStyledAttributes(this, styleable)
    action(typeArray)
    typeArray.recycle()
}
